<template>
  <footer>
    <ul>
      <li
        v-for="(item, index) in navList"
        :key="index"
        :class="{ active: colorNum.startsWith(item.url) }"
        @click="changeRoute(item.url, index)"
      >
        <span class="iconfont" :class="item.icon"></span>
        <p>{{ item.title }}</p>
      </li>
    </ul>
  </footer>
</template>

<script>
export default {
  data() {
    return {
      navList: [
        {
          title: "电影/影院",
          icon: "icon-dianying",
          url: "/home/index",
        },
        {
          title: "视频",
          icon: "icon-dianshi",
          url: "/home/video",
        },
        {
          title: "小视频",
          icon: "icon-xiaoshipin",
          url: "/home/smallVideo",
        },
        {
          title: "演出",
          icon: "icon-yanchu1",
          url: "/home/show",
        },
        {
          title: "我的",
          icon: "icon-wode",
          url: "/home/mine",
        },
      ],
      colorNum: sessionStorage.getItem("active")
        ? sessionStorage.getItem("active")
        : "/home/index",
    };
  },
  watch: {
    $route(to, from) {
      console.log(to);
      console.log(from);
      this.colorNum = to.path;
    },
  },
  methods: {
    changeRoute(url) {
      this.colorNum = url;
      sessionStorage.setItem("active", url);
      this.$router.push(url);
    },
  },
};
</script>

<style lang="less" scoped>
@import "../../assets/css/commons.less";
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 48px;
  border-top: 1px solid @border-color;
  background-color: #fff;

  ul {
    width: 100%;
    height: 100%;
    display: flex;

    li {
      flex: 1;
      font-size: @fontSize_12;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-evenly;

      span {
        font-size: @fontSize_18;
      }
    }

    .active {
      color: #f03d37;
    }
  }
}
</style>
